package com.neusoft.ch7.hw.test03;

public class Rectangle extends Shape {

	// 子类新增属性
	private double width;
	private double heigth;

	@Override
	public double calculateArea() {
		// 计算矩形的面积
		return this.heigth * this.width;
	}

	@Override
	public double calculatePer() {
		// 计算矩形的周长
		double perRectangle = (this.heigth + this.width) * 2;
		return perRectangle;
	}

	@Override
	public void showAll() {
		// 输出所有信息
		System.out.println("当前形状是矩形：宽=" + this.width + ",高=" 
				+ this.heigth + ",周长=" + this.calculatePer() + ",面积="
				+ this.calculateArea()+",颜色="+this.calculateColor());

	}

	
	public Rectangle() {
		super();
	}

	public Rectangle(double width, double heigth,String color) {
		super(color); // 调用父类的构造方法设置颜色（二选一）
		//this.setColor(color); // 调用父类的set方法设置颜色（二选一）
		this.width = width;
		this.heigth = heigth;
	}

	public double getWidth() {
		return width;
	}

	public void setWidth(double width) {
		this.width = width;
	}

	public double getHeigth() {
		return heigth;
	}

	public void setHeigth(double heigth) {
		this.heigth = heigth;
	}

}
